package com.youku.component.script;

import java.util.HashMap;
import java.util.Map;

import com.youku.util.StringHelper;

/**
 * 生成脚本执行器的工厂
 * 
 * @author loda
 *
 */
public class ScriptExecutor {

	private static final Map<String, ScriptRunner> executors;

	static {
		executors = new HashMap<>();
		executors.put("sh", new ShellRunner());
		executors.put("py", new PythonRunner());
	}

	public static void execute(String script) {
		ScriptRunner runner = executors.get(StringHelper.suffix(script));

		if (runner == null)
			throw new RuntimeException("无法执行该文件类型的脚本");

		runner.execute(script);
	}
}
